import 'package:full_display/unit/http/dio_manager.dart';
import 'package:full_display/unit/http/http_callback.dart';
import 'package:full_display/unit/http/response_type.dart';

class HttpUtils {
  HttpUtils.internal();

  static HttpUtils instance = HttpUtils.internal();

  Future<dynamic> get(String url,
      {Map<String, dynamic>? params,
      dynamic? body,
      Success? onSuccess,
      Failure? onFailure,
      QbResponseType? responseType}) async {
    return await DioManager.instance.request("GET", url,
        params: params,
        data: body,
        onSuccess: onSuccess,
        onFailure: onFailure,
        responseType: responseType);
  }

  Future<dynamic> post(String url,
      {Map<String, dynamic>? params,
      dynamic? body,
      Success? onSuccess,
      Failure? onFailure,
      QbResponseType? responseType}) async {
    return await DioManager.instance.request("POST", url,
        params: params,
        data: body,
        onSuccess: onSuccess,
        onFailure: onFailure,
        responseType: responseType);
  }

  Future<dynamic> put(String url,
      {Map<String, dynamic>? params,
      dynamic? body,
      Success? onSuccess,
      Failure? onFailure,
      QbResponseType? responseType}) async {
    return await DioManager.instance.request("PUT", url,
        params: params,
        data: body,
        onSuccess: onSuccess,
        onFailure: onFailure,
        responseType: responseType);
  }

  Future delete(String url,
      {Map<String, dynamic>? params,
      dynamic? body,
      Success? onSuccess,
      Failure? onFailure,
      QbResponseType? responseType}) async {
    await DioManager.instance.request("DELETE", url,
        params: params,
        data: body,
        onSuccess: onSuccess,
        onFailure: onFailure,
        responseType: responseType);
  }
}
